;(function (doc, win) {
  var docEl = win.document.documentElement
  var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'

  var refreshRem = function () {
    var clientWidth =
      win.innerWidth || doc.documentElement.clientWidth || doc.body.clientWidth

    if (!clientWidth) return
    var fz
    var width = clientWidth
    fz = (20 * width) / 375 // iponeX,根字体为20px
    window.winFontSize = fz
    docEl.style.fontSize = fz + 'px' //这样每一份也是20px,即1rem=20px
  }

  const RegExpStr =
    /(nokia|iphone|android|ipad|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220)/i
  window.mobile = RegExpStr.test(navigator.userAgent)

  if (window.mobile) {
    if (!doc.addEventListener) return
    win.addEventListener(resizeEvt, refreshRem, false)
    doc.addEventListener('DOMContentLoaded', refreshRem, false)
    refreshRem()
    document.getElementById('app').classList.add('mobile')
  } else {
    document.getElementById('app').classList.add('desktop')
  }
})(document, window)
